package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.enumwrap.InfoMationAuditStatus;
import com.ygxsk.carhome.response.ArchivesManageVo;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-17  16:07
 * @Description:档案管理详情的适配器，主要是合同的小列表适配器
 */
public class ArchiveDetailAgreenAdapter extends BaseQuickAdapter<ArchivesManageVo, BaseViewHolder> {

    //当前档案的核销状态
    private String auditStatus;

    public ArchiveDetailAgreenAdapter(int layoutResId) {
        super(layoutResId);
    }

    public ArchiveDetailAgreenAdapter(int layoutResId, @Nullable List<ArchivesManageVo> data, String _auditStatus) {
        super(layoutResId, data);
        auditStatus = _auditStatus;
        addChildClickViewIds(R.id.roundtextvieweditagreenment);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ArchivesManageVo informationManageVo) {

        if (informationManageVo != null) {

            //合同的类型:文本信息的
            String agreenTypeInfo = informationManageVo.getArchivesTypeName();
            //签约时间
            String agreenTime = informationManageVo.getSigningDate();
            //签约人:文本信息的
            String partyA = informationManageVo.getPartyA();
            //合同的签约编号:合同编号没有，用 签约人，签约人有值
            String agreenNumber = informationManageVo.getArchiveNo();
            //findviews

            //合同顶部的【添加合同】
            RelativeLayout lineLayoutTiteTopForAgreement = (RelativeLayout) baseViewHolder.findView(R.id.linelayouttitetopforagreement);
            //添加合同的按钮
            RoundTextView roundTextViewEditAgreenment = (RoundTextView) baseViewHolder.findView(R.id.roundtextvieweditagreenment);
            //合同的类型
            TextView textViewAgreenInfoType = (TextView) baseViewHolder.getView(R.id.textviewagreeninfotype);
            //签约人
            TextView textViewAgreenPersonInfo = (TextView) baseViewHolder.getView(R.id.textviewagreenpersoninfo);
            //合同编号
            TextView textViewAgreenNumberInfo = (TextView) baseViewHolder.getView(R.id.textviewagreennumberinfo);
            //合同的签约时间
            TextView textViewAgreenTimeInfo = (TextView) baseViewHolder.getView(R.id.textviewagreentimeinfo);

            //【添加合同】的按钮的显示和隐藏；
            int indexPosition = getItemPosition(informationManageVo);
            if (indexPosition == 0) {
                lineLayoutTiteTopForAgreement.setVisibility(View.VISIBLE);
            } else {
                lineLayoutTiteTopForAgreement.setVisibility(View.GONE);
            }

            if (!TextUtils.isEmpty(agreenTypeInfo)) {
                CommUtils.setViewVisible(textViewAgreenInfoType);
                CommUtils.setText(textViewAgreenInfoType, agreenTypeInfo);
            } else {
                //依然占位
                CommUtils.setViewInvisible(textViewAgreenInfoType);
//              CommUtils.setText(textViewAgreenInfoType, agreenTypeInfo);
            }

            CommUtils.setText(textViewAgreenTimeInfo, agreenTime);
            //签约人
            CommUtils.setText(textViewAgreenPersonInfo, partyA);
            //合同编号 有时候有 ，有时候没有；
            CommUtils.setText(textViewAgreenNumberInfo, agreenNumber);

            //                    InfoMationAuditStatus
//                AUDITSTATUS_INPUTING(0, "填写中"), //填写中
//                AUDITSTATUS_TO_BE_VERIFY(1, "待审核"),//待审核
//                AUDITSTATUS_HAS_PASS(2, "通过"),//通过
//                AUDITSTATUS_NOT_PASS(3, "不通过");//不通过

            if (TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_INPUTING.getIndex()))//
                    || TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()))//
                    || TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()))//
            ) {

//                CommUtils.RoundTextViewButtonEnable(roundTextViewEditAgreenment);
                CommUtils.setViewVisible(roundTextViewEditAgreenment);

            } else if (TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_HAS_PASS.getIndex()))) {

//                CommUtils.RoundTextViewButtonNotUse(roundTextViewEditAgreenment);
                CommUtils.setViewGone(roundTextViewEditAgreenment);

            }


//            if (roundTextViewEditAgreenment!=null){
//                roundTextViewEditAgreenment.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
//
//
//                    }
//                });
//            }

        }
    }
}
